import logging, HTMLTestRunner_cn, BeautifulReport, yagmail


class Tools():

    def Log(self):
        log = logging.basicConfig(level=logging.DEBUG,
                                  format='%(levelname)s -> %(filename)s -> %(message)s -> %(asctime)s -> %(lineno)d',
                                  filename='baidu.log',
                                  filemode='a+')
        return log
    def Report1(self):
        report1 = HTMLTestRunner_cn.HTMLTestRunner(open('baidu1.html', 'wb'), title='百度项目的测试报告', description='请注意查收测试报告')
        return report1
    def Report2(self, suite):
        report2 = BeautifulReport.BeautifulReport(suites=suite)
        report2.report(filename='baidu2.html', description='请注意查收测试报告2', log_path='.', report_dir='.')

    def mail(self):
        mail = yagmail.SMTP(user='2318636512@qq.com', password='oonwmxkqqgyodibd', host='smtp.qq.com', port='465')
        mail.send(to='2318636512@qq.com', subject='百度项目的日志文件和测试报告', contents=['请注意查收日志和测试报告', 'baidu.log', 'baidu1.html'], attachments='baidu2.html')
        mail.close()